package tjx.Listener;

import javax.servlet.ServletContext;
import javax.servlet.ServletContextAttributeEvent;
import javax.servlet.ServletContextEvent;
import javax.servlet.ServletContextListener;
import javax.servlet.annotation.WebListener;
import javax.servlet.http.HttpSessionAttributeListener;
import javax.servlet.http.HttpSessionEvent;
import javax.servlet.http.HttpSessionListener;
import javax.servlet.http.HttpSessionBindingEvent;

//@WebListener()
public class MyServletContextAttributeListener implements ServletContextListener{
    public void attributeAdded(ServletContextAttributeEvent sbe) {
        ServletContext application=sbe.getServletContext();
        String name=sbe.getName();
        Object value=sbe.getValue();
        System.out.println(application+"范围内添加了名为"+name+",值为"+value+"的属性！");
    }

    public void attributeRemoved(ServletContextAttributeEvent sbe) {
        ServletContext application=sbe.getServletContext();
        String name=sbe.getName();
        Object value=sbe.getValue();
        System.out.println(application+"范围内名为"+name+",值为"+value+"的属性被删除了！");
    }

    public void attributeReplaced(ServletContextAttributeEvent sbe) {
        ServletContext application=sbe.getServletContext();
        String name=sbe.getName();
        Object value=sbe.getValue();
        System.out.println(application+"范围内名为"+name+",值为"+value+"的属性被替换了！");
    }

    public void contextInitialized(ServletContextEvent servletContextEvent) {

    }

    public void contextDestroyed(ServletContextEvent servletContextEvent) {

    }
}
